/* -----------------------------------
 *  WARNING:
 * -----------------------------------
 *  Your code may fail to compile
 *  because it contains public class
 *  declarations.
 *  To fix this, please remove the
 *  "public" keyword from your class
 *  declarations.
 */

/* The isBadVersion API is defined in the parent class VersionControl.
      boolean isBadVersion(int version); */

public class Solution extends VersionControl {
    public int firstBadVersion(int n) {
        //分析极端情况
        if (n==1) return 1;
        //二分查找，定义一个high 和low 和mid ；
        int mid ;
        int left = 1; 
        int right = n;
        //一直执行直到，左右指针两个相邻为止
        while(right >= left ){
            //这里注意一下 >> 和>>>的区别 一个有符号，一个无符号
            mid = (right + left ) >>>1;
            if (isBadVersion(mid)){
                right =mid-1 ;
            }else{
                left = mid+1 ;
            }
        }
        return right+1;
    }
}

public class MainClass {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = in.readLine()) != null) {
            int n = Integer.parseInt(line);
            line = in.readLine();
            int bad = Integer.parseInt(line);
            
            int ret = new Solution().firstBadVersion(n, bad);
            
            String out = String.valueOf(ret);
            
            System.out.print(out);
        }
    }
}